package com.leetcode.basic.synchronize;

public class ThreadTest {


	public static void main(String[] args) throws InterruptedException {
		Object lock = new Object();

		A a = new A();

		// 一段时间后，await a
		new Thread(() -> {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			synchronized (a) {
				System.out.println("a.notify()");
				a.notify();
			}
		}).start();

		a.run();

		System.out.println("----");
	}

	private static class A implements Runnable {

		@Override
		public void run() {
			System.out.println("run");
			try {
				synchronized (this) {
					wait();
				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println("await");
		}
	}
}
